﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;

namespace ExpertMIS.Admin.Service
{
    public partial class UploadFile : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string filename = Guid.NewGuid().ToString();
            if (Request.Files.Count > 0)
            {
                string filepath = Server.MapPath(ConfigurationManager.AppSettings["UserUpload"]);

                Request.Files[0].SaveAs(filepath + filename);

                Response.Clear();
                Response.ContentType = "text/plain";
                Response.Write(ResolveClientUrl(ConfigurationManager.AppSettings["UserUpload"]) + filename);
                Response.End();
            }
            else
            {
                Response.Clear();
                Response.ContentType = "text/plain";
                Response.Write("error");
                Response.End();
            }
        }
    }
}
